<?php
defined('IN_XLP') or exit('Access Denied');
$Document = array(
    'pageid'   => 'task-user', //页面标示
    'pagename' => '用户列表', //当前页面名称
    'mycss'    => array('../jquery-ui/css/smoothness/jquery-ui-1.10.0.custom.min'), //加载的css样式表
    'myjs'     => array('../jquery-ui/js/jquery-ui-1.10.0.custom.min', '../jquery-ui/js/jquery-ui-timepicker-addon'), //加载的js脚本
    'footerjs' => array(),
    'head'     => true, //加载头部文件
);
include getTpl('header', 'public');
?>
<style>
tr th,tr td{text-align:center}
tr td img{border-radius:30px}
.txl{text-align:left}
.w14{width:14% !important;}
.hide{display:none;}
.red{color:red;}
</style>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<!-- content -->
<section id="content">
    <!-- main padder -->
    <section class="main padder">
        <div class="clearfix">
            <h4><i class="fa fa-table"></i>用户列表</h4>
            <section class="panel">
                    <div class="panel-body hide" >
                        <div class="row text-small">
                            <form action="<?php echo U('task/user'); ?>" method="get">
                                <input type="hidden" name="g" value="content">
                                <input type="hidden" name="c" value="task">
                                <input type="hidden" name="m" value="user">
                                <!-- <div class="col-sm-2 w14">
                                    <label for="">开始时间 <input class="input-sm" name="starttime" id="starttime" size="16" type="text" value="<?php //echo $starttime; ?>" readonly ></label>
                                </div>
                                <div class="col-sm-2 w14">
                                    <label for="">结束时间 <input class="input-sm" name="endtime" id="endtime" size="16" type="text" value="<?php //echo $endtime; ?>" readonly ></label>
                                </div> -->
                                <div class="col-sm-2 w14">
                                    <div class="input-group">
                                        <input type="text" class="input-sm form-control" placeholder="任务名称" name="keyword" id="keyword" value="<?php //echo $keyword; ?>">
                                        <span class="input-group-btn">
                                            <button class="btn btn-sm btn-white" type="submit">搜索</button>
                                        </span>
                                    </div>
                                </div>
                                <div class="col-sm-2">
                                    <div class="input-group">
                                        <!-- <a class="btn btn-sm btn-white" href="<?php //echo U('task/index',array('export'=>1,'starttime'=>$starttime,'endtime'=>$endtime,'keyword'=>$keyword)); ?>">导出CSV</a> -->
                                        <a style="margin-left:25px;" class="btn btn-sm btn-white" href="<?php echo U('task/index'); ?>">搜索重置</a>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>

                    <div class="table-responsive">
                        <table class="table table-striped b-t text-small">
                            <thead>
                                <tr>
                                    <th width="80">序号</th>
                                    <th width="">UID</th>
                                    <th width="">昵称</th>
                                    <th width="">任务总数</th>
                                    <th width="">积分总数</th>
                                    <th width="">结邻币总数</th>
                                    <th width="">注册时间</th>
                                    <th width="">状态</th>
                                    <th width="">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach ($user_list as $k => $v): ?>
                                <tr>
                                    <td><?php echo $k+1 ?></td>
                                    <td><?php echo $v['uid'] ?></td>
                                    <td><?php echo $v['nickname'] ?></td>
                                    <td><?php echo $v['task_total'] ?></td>
                                    <td><?php echo $v['reward_credit'] ?></td>
                                    <td><?php echo $v['reward_coin'] ?></td>
                                    <td><?php echo $v['reg_time'] ?></td>
                                    <td><?php echo $v['status'] ?></td>
                                    <td>
                                        <?php if ($v['state']): ?>
                                        <a href="javascript:freeze(<?php echo $v['uid'] ?>);">冻结</a>
                                        <?php else: ?>
                                        <a href="javascript:melt(<?php echo $v['uid'] ?>);" class="red">解冻</a>
                                        <?php endif ?>
                                    </td>
                                </tr>
                                <?php endforeach ?>
                            </tbody>
                        </table>
                    </div>
                    
                    <footer class="panel-footer">
                        <div class="row">
                            <div class="col-sm-12 text-right text-center-sm">
                                <?php echo page($total,$page,'', 20, 'page');?>
                            </div>
                        </div>
                    </footer>

                </div>
            </section>
        </div>
    </section>
    <!--/ main padder -->
</section>
<!--/ content -->
<!--主体 结束-->
<script>
function change_state(uid) {
    $.post('<?php echo U("task/change_state") ?>', {"uid":uid}, function(result){
        if(result.status==1) {
            if(result.data==1) {
                Msg.ok('已解冻');
            } else {
                Msg.ok('已冻结');
            }
            self.location.reload();
        } else {
            Msg.error(result.info);
        }
    }, 'JSON');
}

function freeze(uid) {
    if(!confirm('确定要冻结此用户吗？')) return false;
    change_state(uid);
}
function melt(uid) {
    if(!confirm('确定要解冻此用户吗？')) return false;
    change_state(uid);
}
$(function(){
    $('#starttime').datetimepicker();
    $('#endtime').datetimepicker();
});
</script>
<?php include getTpl('footer', 'public'); ?>